#pragma once


#include <opencv2/ml.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>

#define TBB

#ifdef TBB
#include<tbb/tbb.h>
#endif // TBB

#ifndef DLL_IMPORT
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif 



class API ClassifyMLP
{
public:
    void train(std::vector<std::vector<float>> traindatas, std::vector<int> trainlabel, int classnum);
    void train(std::vector<cv::Mat> trainimages, std::vector<int> trainlabel, int classnum);
    void var(std::vector<std::vector<float>> vardatas, std::vector<int> varlabel, std::vector<std::string> names);
    void var(std::vector<cv::Mat> varimages, std::vector<int> varlabel, std::vector<std::string> names);

    void setnormal(cv::Size size, bool isgray, float value);
    void load(const char* path);
    void save(const char* path);
    int predicter(std::vector<float> input, int featruesize = 224);
    int predicter(const cv::Mat& input);
    void Release();

private:
    void enhance(const std::vector<cv::Mat>& inputimages,
        const std::vector<int>& inputlabels,
        std::vector<cv::Mat>& expandimages,
        std::vector<int>& expandlabels);

    void normalimage(const cv::Mat& originalimage, cv::Mat& normalimage);
    void gammaimage(const cv::Mat& src, cv::Mat& dst, float gamma);

    bool istrained = false;
    cv::Ptr<cv::ml::TrainData> tdata;
    cv::Ptr<cv::ml::ANN_MLP> mlp;
    int featuresize;
    cv::Size normalsize;
    bool isgray;
    float normalvalue;
    std::string filepath;

};